package com.yz.api.facade.user;

import com.yz.model.dto.user.*;
import com.yz.model.vo.LoginUserVo;
import com.yz.common.resp.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * author: Mr.Du
 * Date: 2023/11/27
 * Time: 19:33
 */
@Tag(name = "用户接口")
public interface UserFacade {

    @Operation(summary = "登录请求")
    @PostMapping("/user/login")
    BaseResponse<String> login(@RequestBody UserLoginRequest userLoginRequest);

    @Operation(summary = "登录请求")
    @PostMapping("/user/loginWithEmail")
    BaseResponse<String> userLoginWithEmail(@RequestBody UserLoginWithEmailRequest userLoginWithEmailRequest);

    @Operation(summary = "注册请求")
    @PostMapping("/user/register")
    BaseResponse<Long> register(@RequestBody UserRegisterRequest userRegisterRequest);

    @Operation(summary = "删除用户")
    @Parameters(value = {@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH)})
    @DeleteMapping("/user/{id}")
    BaseResponse<Long> deleteUser(@PathVariable Long id);

    @Operation(summary = "更改密码请求")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER)})
    @PostMapping("/user/update/passwd")
    BaseResponse<Boolean> updatePassword(@RequestHeader Long uid, @RequestBody UpdatePasswordRequest updatePasswordRequest);

    @Operation(summary = "注册获取验证码")
    @Parameters(value = {@Parameter(name = "email", description = "注册邮箱", in = ParameterIn.PATH)})
    @GetMapping("/user/code/{email}")
    BaseResponse<Boolean> getCode(@PathVariable String email);

    @Operation(summary = "校验用户名或者邮箱是否存在")
    @Parameters(value = {@Parameter(name = "info", description = "验证用户名", in = ParameterIn.PATH)})
    @GetMapping("/user/check/{info}")
    BaseResponse<Boolean> checkUsername(@PathVariable String info);

    @Operation(summary = "获取当前用户信息")
    @Parameters(value = {@Parameter(name = "username", description = "用户名", in = ParameterIn.HEADER)})
    @GetMapping("/user/current/info")
    BaseResponse<LoginUserVo> getCurrentUserInfo(@RequestHeader String username);

    @Operation(summary = "根据id获取用户信息")
    @Parameters(value = {@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH)})
    @GetMapping("/user/{id}")
    LoginUserVo getUserById(@PathVariable Long id);

    @Operation(summary = "根据id更新用户countPromotion")
    @Parameters(value = {@Parameter(name = "id", description = "用户id", in = ParameterIn.PATH),
            @Parameter(name = "countPromotion", description = "用户countPromotion", in = ParameterIn.PATH)}
    )
    @GetMapping("/user/{id}/{countPromotion}")
    void updateUserCountPromotion(@PathVariable Long id, @PathVariable Integer countPromotion);

    @Operation(summary = "消费")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER),
            @Parameter(name = "amount", description = "金额", in = ParameterIn.PATH)})
    @PostMapping("/user/consume/{amount}")
    BaseResponse consumeAmount(@RequestHeader Long uid, @PathVariable Long amount);

    @Operation(summary = "充值")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER),
            @Parameter(name = "amount", description = "金额", in = ParameterIn.PATH)})
    @PostMapping("/user/recharge/{amount}")
    BaseResponse<Boolean> reChargeAmount(@RequestHeader Long uid, @PathVariable Long amount);

    @Operation(summary = "退出")
    @Parameters(value = {@Parameter(name = "username", description = "用户名", in = ParameterIn.HEADER)})
    @PostMapping("/user/logout")
    BaseResponse<Boolean> logout(@RequestHeader String username, HttpServletResponse response);

    @Operation(summary = "更新请求")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER)})
    @PutMapping("/user")
    BaseResponse<Long> updateUser(@RequestHeader Long uid, @RequestBody UpdateUserInfoRequest updateUserInfoRequest);

    @Operation(summary = "更新count")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER),
            @Parameter(name = "countPromotion", description = "金额", in = ParameterIn.PATH)})
    @PostMapping("/user/update/promotion/{countPromotion}")
    BaseResponse<Boolean> updateCountPromotion(@RequestHeader Long uid, @PathVariable Integer countPromotion);

    @Operation(summary = "校验邮箱是否为当前账户")
    @Parameters(value = {@Parameter(name = "uid", description = "用户id", in = ParameterIn.HEADER),
            @Parameter(name = "email", description = "邮箱", in = ParameterIn.PATH)})
    @GetMapping("/user/current/{email}")
    BaseResponse<Boolean> checkEmailIsCurrent(@RequestHeader Long uid, @PathVariable String email);



}
